<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <link href="css/login.css" rel="stylesheet">
    <script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
    </script>
</head>
<body>
<div class="htmleaf-container">
    <div id="wrapper" class="login-page">
        <div id="login_form" class="form">
            <form id="login_form" class="login-form">
                <input type="text" placeholder="用户名" id="username" name="username" />
                <input type="password" placeholder="密码" id="password" name="password"/>
                <button type="button" id="login">登　录</button>
                <p class="error" style="color: red" id="error"></p>
            </form>
        </div>
    </div>
</div>

<script src="js/jquery.min.js?v=2.1.4"></script>
<script type="text/javascript">

    $(function () {
        $("#login").click(function () {
            var username = $("#username").val();
            var password = $("#password").val();
            if(username == ""){
	            $("#error").html("请输入用户名");
	            return false;
            }else if(password == "") {
	            $("#error").html("请输入密码");
	            return false;
            }
            $.ajax({
                url:'${ctx}/admin/loginValid',
                data:{
                    'username':username,
                    'password':password
                },
                type:'post',
                dataType:'json',
                success:function(data){
                    if(data.status == "200"){
                        window.location.href="/admin";
                    }else{
                        $("#error").html(data.message);
                        $("#login_form").removeClass('shake_effect');
                        setTimeout(function () {
                            $("#login_form").addClass('shake_effect')
                        }, 1);
                    }
                }
            })
        })
    })
</script>
</body>
</html>